//
//  FatherViewController.m
//  yunyan
//
//  Created by haichuang on 2018/2/11.
//  Copyright © 2018年 haichuang. All rights reserved.
//

#import "FatherViewController.h"

@interface FatherViewController ()

@end

@implementation FatherViewController

- (void)viewDidLoad {
    
    
    [super viewDidLoad];
    
    
}
- (void)customNaviItemTitle:(NSString *)title isLeft:(BOOL)isLeft
{
    self.view.backgroundColor = RGBA(243, 245, 248, 1);

    //获取当前的NavigationBar
    UINavigationBar * naviBar = self.navigationController.navigationBar;
    naviBar.translucent = NO;

    naviBar.barTintColor = [UIColor whiteColor];


    // 定制UINavigationItem的titleView
    UILabel * titleLabel = [[UILabel alloc]  initWithFrame:CGRectMake(0, 0, 100, 44)];
    titleLabel.textAlignment = NSTextAlignmentCenter;
    titleLabel.font = [UIFont boldSystemFontOfSize:18];
    titleLabel.textColor = RGBA(51, 51, 51, 1);
    // 设置文字
    titleLabel.text = title;

    // 设置导航项的标题视图
    self.navigationItem.titleView = titleLabel;
    
    [self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
    [self.navigationController.navigationBar setShadowImage:[UIImage new]];
    
    //返回
    if (isLeft) {
        UIButton *leftBtn   =   [UIButton buttonWithType:UIButtonTypeCustom];
        leftBtn.frame       =   CGRectMake(0, 0, 24, 24);
        [leftBtn setTitle:nil forState:UIControlStateNormal];
        [leftBtn addTarget:self action:@selector(leftButtonEvent:) forControlEvents:UIControlEventTouchUpInside];
        leftBtn.titleLabel.font    = [UIFont systemFontOfSize:16.0f];
        [leftBtn setImage:[UIImage imageNamed:@"currency_back_default"] forState:UIControlStateNormal];
        [leftBtn setContentMode:UIViewContentModeCenter];
        
        UIBarButtonItem *leftButton            =   [[UIBarButtonItem alloc]initWithCustomView:leftBtn];
        self.navigationItem.leftBarButtonItem  =  leftButton;

    }
   
  
    
}
-(void)leftButtonEvent:(UIButton *)sender{
    [self.navigationController popViewControllerAnimated:YES];
}



- (void)customTabBarButtonTitle:(NSString *)title image:(UIImage *)imageName target:(id)target action:(SEL)selector isLeft:(BOOL)isLeft
{
    UIButton * button = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, 36, 26)];
    
    [button setImage:imageName forState:UIControlStateNormal];
    [button setTitleColor:RGBA(51, 51, 51, 1) forState:UIControlStateNormal];
    button.titleLabel.font = [UIFont systemFontOfSize:15.0f];
    [button setTitle:title forState:UIControlStateNormal];
    [button addTarget:target action:selector forControlEvents:UIControlEventTouchUpInside];
   
    // 判断是否为左侧按钮
    UIBarButtonItem * buttonItem = [[UIBarButtonItem alloc] initWithCustomView:button];
    if (isLeft) {
        self.navigationItem.leftBarButtonItem = buttonItem;
    }
    else {
        self.navigationItem.rightBarButtonItem = buttonItem;
    }
}
@end

